﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Threading.Tasks;

namespace YellowMap.View.Control
{
    public partial class HistoryControl : UserControl
    {
        public HistoryControl()
        {
            InitializeComponent();
            Init();
        }
        async void Init()
        {
            await UpdateHistory();
            lbHistoryItem.ItemsSource = AppViewModel.Instance.HistoryVM.Histories;
        }
        async Task UpdateHistory()
        {
            await AppViewModel.Instance.HistoryVM.Update();
        }

        async void DeleteHistory()
        {
            await DBHelper.ClearAllHistory();
            Init();
        }

        private void btnDeleteAll_Click(object sender, RoutedEventArgs e)
        {
            DeleteHistory();
        }
    }
}
